-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Deny unmasked frame receive for WebSocket Server #123485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deny unmasked frame receive for WebSocket Server #123485
Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances RFC 6455 compliance for WebSocket servers by adding validation to reject unmasked frames from clients. According to the RFC, clients must mask all frames sent to servers, and servers should reject unmasked frames.
Changes:
- Added validation logic to reject unmasked frames when running as a WebSocket server
- Added a test case to verify the server properly rejects unmasked frames with appropriate error handling
- Added a new resource string for the error message
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs | Adds server-side validation to reject unmasked frames, mirroring the existing client-side check for masked frames |
| src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs | Adds test to verify server rejects unmasked frames and transitions to Aborted state |
| src/libraries/System.Net.WebSockets/src/Resources/Strings.resx | Adds error message resource for unmasked frame rejection |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CarnaViire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
/backport to release/10.0 |
|
Started backporting to |
|
/backport to release/9.0-staging |
|
Started backporting to |
|
/backport to release/8.0-staging |
|
Started backporting to |
|
@liveans backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Deny unmasked frame receive on server
.git/rebase-apply/patch:53: trailing whitespace.
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M src/libraries/System.Net.WebSockets/src/Resources/Strings.resx
M src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
M src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Net.WebSockets/src/Resources/Strings.resx
Auto-merging src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
Auto-merging src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.Net.WebSockets/tests/WebSocketTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Deny unmasked frame receive on server
Error: The process '/usr/bin/git' failed with exit code 128 |
Increasing RFC-compliance for WebSocket